#!/bin/bash

# ROOT 密码
rootpass=redhat

SSH_KEY(){
/usr/bin/expect <<EOF
set timeout 30
spawn ssh-copy-id -i /root/.ssh/id_dsa.pub root@$1
expect {
    "(yes/no)?" { send "yes\r"; exp_continue }
    "password:" { send "$rootpass\r" }
}
expect eof
EOF
}

# 生成密钥
[ -f ~/.ssh/id_dsa ] || { ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa; }

# 安装 expect
[ -f /usr/bin/expect ] || { yum -y install expect; }
